<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
    protected function _initAutoload(){
      $loader = new Zend_Loader_Autoloader_Resource(array(
            'basePath' => APPLICATION_PATH,
            'namespace' => '',
            'resourceTypes' => array(
                'form' => array(
                    'path' => 'forms/',
                    'namespace' => 'Form'
                ),
                'model' => array(
                    'path' => 'models/',
                    'namespace' => 'Model'
                )
            )
        ));
        
        $autoloader = Zend_Loader_Autoloader::getInstance();
//         $autoloader->registerNamespace('Base_');
        //$loader = Zend_Loader_Autoloader::getInstance();
        //$loader->registerNamespace('App_');
       // $loader->setFallbackAutoloader(true);
    }
    
    protected function _initCache(){
        $frontendOptions = array(
           'lifetime' => 7200,
           'automatic_serialization' => true
        );
         
        $backendOptions = array(
            'cache_dir' => APPLICATION_PATH.'/cache/'
        );
         
        $cache = Zend_Cache::factory('Core','File',$frontendOptions,$backendOptions);
        Zend_Registry::getInstance()->set('cache', $cache);
        Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
    }
    
    protected function _initRouting(){
        $routing = new Zend_Config_Yaml(APPLICATION_PATH.'/configs/routing.yml');
        $routes = $routing->toArray();
        $router = Zend_Controller_Front::getInstance()->getRouter();
        foreach($routes as $key => $val){
            $router->addRoute($key, new Zend_Controller_Router_Route($val['route'], $val['defaults']));
        }
    }
}

